package cn.blogsx.datasource.c3p0;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.sun.org.apache.bcel.internal.generic.ACONST_NULL;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
/*
   c3p0演示
 */
public class C3P0Demo2 {
    public static void main(String[] args) throws SQLException {
        //1、创建数据库连接池对象
        DataSource ds = new ComboPooledDataSource();
        //2、验证最大连接数
        for (int i = 0; i < 11; i++) {
            Connection connection = ds.getConnection();
            System.out.println(i+":"+connection);
            if(i==5){
                connection.close();
            }
        }

    }
}
